import * as React from "react";
import * as LocationProps from "../common/locationProps";

interface ButtonProps {
    readonly text: string,
    readonly onClicked: (button: Button) => void
}

class Button extends React.Component<ButtonProps & Partial<LocationProps.LocationProps>> {
    constructor(p: ButtonProps) {
        super(p);
    }

    render() {
        const prop = LocationProps.MergeClassNames(["button"], this.props);

        return (
            <button type="button"
                className={LocationProps.ClassNameString(prop)}
                id={prop.id}
                onClick={_ => this.props.onClicked(this)} >
                {this.props.text}
            </button>
        )
    }
}

export default Button;